package com.ost.kautilya.modeling;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;

public abstract class ModelEvaluation implements Serializable {
	private static final long serialVersionUID = 1L;

	private int evaluationBatch;
	private String modelId;
	private int trainingBatch;
	private double maxCost = 0;
	private List<Map<EvaluationMetric, Double>> metrics = new ArrayList<Map<EvaluationMetric, Double>>();

	private double[][] matrix = new double[0][0];

	private byte[] output = new byte[0];

	public byte[] getOutput() {
		return output;
	}

	public ModelEvaluation(int classSize, byte[] output) {
		for (int i = 0; i < classSize; i++) {
			metrics.add(new Hashtable<EvaluationMetric, Double>());
		}
		this.output  = output;
	}

	protected void setMatrix(double[][] matrix) {
		this.matrix = matrix;
	}

	public void setMetric(int cli, EvaluationMetric name, double value) {
		if (!((Double) value).isNaN())
			metrics.get(cli).put(name, value);
	}

	public Double getMetric(int cli, EvaluationMetric name) {
		return metrics.get(cli).get(name);
	}

	public Map<EvaluationMetric, Double> getMetrics(int cli) {
		return metrics.get(cli);
	}

	public double getEvaluationCost() {
		return maxCost;
	}

	public int getTrainingBatch() {
		return trainingBatch;
	}

	public void setTrainingBatch(int trainingBatch) {
		this.trainingBatch = trainingBatch;
	}

	public String getModelId() {
		return modelId;
	}

	public void setModelId(String modelId) {
		this.modelId = modelId;
	}

	public int getEvaluationBatch() {
		return evaluationBatch;
	}

	public void setEvaluationBatch(int evaluationBatch) {
		this.evaluationBatch = evaluationBatch;
	}

	public void setEvaluationCost(double l) {
		maxCost = l;
	}

	public double[][] getConfusionMatrix() {
		return matrix;
	}
}
